package com.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;

import java.util.Arrays;

@Aspect
public class LogAspect {

    @Pointcut("execution(public int com.aop.MathCalculator.*(..))")
    public void pointCut(){};

    @Before("pointCut()")
    public void logStart(JoinPoint joinPoint){
        String name = joinPoint.getSignature().getName();
        Object[] args = joinPoint.getArgs();
        System.out.println("......start......" + name + "===" + Arrays.toString(args));
    }

    @After("pointCut()")
    public void logEnd(){
        System.out.println("......end......");
    }

    @AfterThrowing("pointCut()")
    public void logError(){
        System.out.println("......error......");
    }

    @AfterReturning("pointCut()")
    public void logReturn(){
        System.out.println("......return......");
    }
}
